﻿{extend name="public:base" /}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content">
                    <div class="row search-form">
                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <select class="form-control form-control-lg status" name="status">
                                    <option value="">请选择审核状态</option>
                                    <option value="0" {:input(
                                    'status') === '0' ? 'selected' : ''}>待审核</option>
                                    <option value="1" {:input(
                                    'status') == 1 ? 'selected' : ''}>审核通过</option>
                                    <option value="2" {:input(
                                    'status') == 2 ? 'selected' : ''}>审核驳回</option>
                                    <option value="3" {:input(
                                    'status') == 3 ? 'selected' : ''}>已打款</option>
                                </select>
                            </div>
                        </div>

                        <div class="col-sm-2 m-b-sm">
                            <div class="input-group">
                                <button type="button" class="btn btn-primary btn-lg screen-btn">搜索</button>
                            </div>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>昵称</th>
                                <th>手机号</th>
                                <th>收款二维码</th>
                                <th>提现金额</th>
                                <th>状态</th>
                                <th>驳回原因</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="list" id="vo"}
                            <tr>
                                <td>{$vo.id}</td>
                                <td>{$vo.username}</td>
                                <td>{$vo.mobile}</td>
                                <td><img src="{$vo.payment_qr}" style="width: 150px;height: 150px; object-fit: cover;" /></td>
                                <td>{$vo.price} 元</td>
                                <td>{$vo.status|doWithdrawalStatus}</td>
                                <td>{$vo.remark}</td>
                                <td>{:timeFormat($vo.create_time)}</td>
                                <td class="project-actions">
                                    {if $vo.status == 0}
                                    <a href="{:url('agreeWithdrawal', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate">
                                        <i class="iconfont icon-success"></i> 通过
                                    </a>
                                    <a onclick="setId(`{$vo.id}`)" class="btn btn-white btn-sm" data-toggle="modal" data-target="#myModal2">
                                        <i class="iconfont icon-refuse"></i> 驳回
                                    </a>
                                    {elseif $vo.status == 1}
                                    <a href="{:url('payedWithdrawal', ['id' => $vo.id])}" class="btn btn-white btn-sm ajax-operate">
                                        <i class="iconfont icon-tixian"></i> 已打款
                                    </a>
                                    {/if}
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                        {if !empty($list)}{$list->render()}{/if}
                    </div>

                </div>
            </div>
        </div>

    </div>

    <!--    修改密码弹框    -->
    <div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content animated flipInY">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">
                        <span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">驳回</h4>
                </div>
                <div class="modal-body">
                    <input type="text" class="form-control remark" placeholder="请输入驳回原因">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white close-model" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="confirmRefuse">确认修改</button>
                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"}
<script>

    var id = 0;

    function setId(set_id) {
        id = set_id;
    }

    // 修改密码
    $('#confirmRefuse').click(function () {
        var remark = $('.remark').val();

        var url = "/admin/manage/refuseWithdrawal";

        $.post(url, {
            id, remark
        }, function (res) {
            console.log(res)
            layer.msg(res.msg)
            if (res.result == 1) {
                $(".close-model").trigger("click");
                setTimeout(() => {
                    window.location.reload();
                }, 500)
            }
        }, 'json')
    })
</script>{/block}